package io.renren.modules.jxgkquestion.service.impl;

import io.renren.modules.jxgkquestion.dao.QuestionBankDao;
import io.renren.modules.jxgkquestion.entity.QuestionBankEntity;
import io.renren.modules.jxgkquestion.entity.ScoreDataEntity;
import io.renren.modules.jxgkquestion.service.QuestionBankService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class QuestionBankServiceImpl implements QuestionBankService{
    @Autowired
    QuestionBankDao questionBankDao;
    public List<QuestionBankEntity> queryList(Map<String, Object> map){
        return questionBankDao.queryList(map);
    }
    public int queryTotal(Map<String, Object> map){
        return  questionBankDao.queryTotal(map);
    }
    public void deleteBatch(String[] termIds){
        questionBankDao.deleteBatch(termIds);
    }
    public void save(QuestionBankEntity ste){
        questionBankDao.save(ste);
    }
    public QuestionBankEntity queryObject(String index){
        return questionBankDao.queryObject(index);
    }
    public void update(QuestionBankEntity ste){
        questionBankDao.update(ste);
    }
    public List<String> findAllSubjectType(){
        return questionBankDao.findAllDepartmentType();
    }
    public List<QuestionBankEntity> findQuestionByDepartmentType(String departmentType){
        return  questionBankDao.findQuestionByDepartmentType(departmentType);
    }
    public ScoreDataEntity findCurrentScoreInfoByIdAndSubject( String scoreStudentId,
                                           String scoreSubjectName){
        return questionBankDao.findCurrentScoreInfoByIdAndSubject(scoreStudentId,scoreSubjectName);
    }
    public void updateScoreAmount(ScoreDataEntity sde){
        ScoreDataEntity exist=questionBankDao.findCurrentScoreInfoByIdAndSubject(sde.getScoreStudentId(),
                                                                    sde.getScoreSubjectName());
        if(exist==null){
            questionBankDao.insertScoreAmount(sde);
        } else {
            questionBankDao.updateScoreAmount(sde);
        }
    }
}
